package org.su.generalmvc.interceptor;

import org.su.generalmvc.core.ActionInvocation;
import org.su.generalmvc.core.Interceptor;


/**
 * 默认前后置拦截器抽象类
 * @author yangchuan
 *
 */
public abstract class MethodInterceptor implements Interceptor {

	
	@Override
	public void destroy() {
		//to do something
	}

	@Override
	public void init() {
		//to do something
	}
	
	/**
	 * 前置拦截方法
	 * @param invocation
	 */
	public void before(ActionInvocation invocation){
		//to do something
        System.out.println("MethodInterceptor拦截器开始");
    }

	/**
	 * 后置拦截方法
	 * @param invocation
	 */
	public void after(ActionInvocation invocation){
		//to do something
        System.out.println("MethodInterceptor拦截器结束");
	}

	
	@Override
	public Object intercept(ActionInvocation invocation) throws Exception {
	
		before(invocation);
		Object result = invocation.invoke();
		after(invocation);
		return result;
	}


}
